package server_gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import net.miginfocom.swing.MigLayout;

import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JLabel;

import server_logic.CcrmServer;
import server_logic.DBconnector;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JPasswordField;

public class ServerGui extends JFrame {

	private JPanel contentPane;
	private JTextField port;
	private JTextField schema;
	private JTextField dbUser;
	private JLabel lblListenPort ;
	private JLabel lblDefaultSchema;
	private JLabel lblDbUser;
	private JLabel lblDbPassword;
	private DBconnector con;
	public JButton connect;
	private JPasswordField passwordField;
	
	/**
	 * Launch the application.
	 */


	/**
	 * Create the frame.
	 */
	public ServerGui() {
		setTitle("ServerGui");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	    this.setSize(400,400);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new MigLayout("", "[][][][][][][grow]", "[][][][][][][][][]"));
		
		lblListenPort = new JLabel("Listen port");
		contentPane.add(lblListenPort, "cell 2 0");
		
		port = new JTextField();
		contentPane.add(port, "cell 6 0,growx");
		port.setColumns(10);
		
		lblDefaultSchema = new JLabel("Default Schema");
		contentPane.add(lblDefaultSchema, "cell 2 2");
		
		schema = new JTextField();
		contentPane.add(schema, "cell 6 2,growx");
		schema.setColumns(10);
		
		lblDbUser = new JLabel("DB user");
		contentPane.add(lblDbUser, "cell 2 4");
		
		dbUser = new JTextField();
		contentPane.add(dbUser, "cell 6 4,growx");
		dbUser.setColumns(10);
		
		lblDbPassword = new JLabel("DB password");
		contentPane.add(lblDbPassword, "cell 2 6");
		
		passwordField = new JPasswordField();
		contentPane.add(passwordField, "cell 6 6,growx");
		
		connect = new JButton("Connect");
		
		
		contentPane.add(connect, "cell 2 8");
		

	}


	public int getPort() {
		return Integer.parseInt(port.getText());
		//return 3333;
	}


	public String getSchema() {
		return schema.getText();
		//return "ccrmg15";
	}


	public String getDbUser() {
		return dbUser.getText();
		//return "root";
	}


	public String getDbPass() {
		
		return passwordField.getText().toString();
		//return "admin";
	}


	
	
}
